.class public Lcom/openfeint/internal/request/multipart/FilePart;
.super Lcom/openfeint/internal/request/multipart/PartBase;
.source "FilePart.java"


# static fields
.field public static final DEFAULT_CHARSET:Ljava/lang/String; = "ISO-8859-1"

.field public static final DEFAULT_CONTENT_TYPE:Ljava/lang/String; = "application/octet-stream"

.field public static final DEFAULT_TRANSFER_ENCODING:Ljava/lang/String; = "binary"

.field protected static final FILE_NAME:Ljava/lang/String; = "; filename="

.field private static final FILE_NAME_BYTES:[B


# instance fields
.field private source:Lcom/openfeint/internal/request/multipart/PartSource;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 72
    const-string v0, "; filename="

    invoke-static {v0}, Lcom/openfeint/internal/request/multipart/EncodingUtil;->getAsciiBytes(Ljava/lang/String;)[B

    move-result-object v0

    .line 71
    sput-object v0, Lcom/openfeint/internal/request/multipart/FilePart;->FILE_NAME_BYTES:[B

    .line 54
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Lcom/openfeint/internal/request/multipart/PartSource;)V
    .locals 1
    .parameter "name"
    .parameter "partSource"

    .prologue
    const/4 v0, 0x0

    .line 109
    invoke-direct {p0, p1, p2, v0, v0}, Lcom/openfeint/internal/request/multipart/FilePart;-><init>(Ljava/lang/String;Lcom/openfeint/internal/request/multipart/PartSource;Ljava/lang/String;Ljava/lang/String;)V

    .line 110
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Lcom/openfeint/internal/request/multipart/PartSource;Ljava/lang/String;Ljava/lang/String;)V
    .locals 3
    .parameter "name"
    .parameter "partSource"
    .parameter "contentType"
    .parameter "charset"

    .prologue
    .line 89
    .line 91
    if-nez p3, :cond_0

    const-string v0, "application/octet-stream"

    .line 92
    :goto_0
    if-nez p4, :cond_1

    const-string v1, "ISO-8859-1"

    .line 93
    :goto_1
    const-string v2, "binary"

    invoke-direct {p0, p1, v0, v1, v2}, Lcom/openfeint/internal/request/multipart/PartBase;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    .line 96
    if-nez p2, :cond_2

    .line 97
    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "Source may not be null"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_0
    move-object v0, p3

    .line 91
    goto :goto_0

    :cond_1
    move-object v1, p4

    .line 92
    goto :goto_1

    .line 99
    :cond_2
    iput-object p2, p0, Lcom/openfeint/internal/request/multipart/FilePart;->source:Lcom/openfeint/internal/request/multipart/PartSource;

    .line 100
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Ljava/io/File;)V
    .locals 2
    .parameter "name"
    .parameter "file"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/FileNotFoundException;
        }
    .end annotation

    .prologue
    const/4 v1, 0x0

    .line 123
    new-instance v0, Lcom/openfeint/internal/request/multipart/FilePartSource;

    invoke-direct {v0, p2}, Lcom/openfeint/internal/request/multipart/FilePartSource;-><init>(Ljava/io/File;)V

    invoke-direct {p0, p1, v0, v1, v1}, Lcom/openfeint/internal/request/multipart/FilePart;-><init>(Ljava/lang/String;Lcom/openfeint/internal/request/multipart/PartSource;Ljava/lang/String;Ljava/lang/String;)V

    .line 124
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;)V
    .locals 1
    .parameter "name"
    .parameter "file"
    .parameter "contentType"
    .parameter "charset"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/FileNotFoundException;
        }
    .end annotation

    .prologue
    .line 141
    new-instance v0, Lcom/openfeint/internal/request/multipart/FilePartSource;

    invoke-direct {v0, p2}, Lcom/openfeint/internal/request/multipart/FilePartSource;-><init>(Ljava/io/File;)V

    invoke-direct {p0, p1, v0, p3, p4}, Lcom/openfeint/internal/request/multipart/FilePart;-><init>(Ljava/lang/String;Lcom/openfeint/internal/request/multipart/PartSource;Ljava/lang/String;Ljava/lang/String;)V

    .line 142
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;Ljava/io/File;)V
    .locals 2
    .parameter "name"
    .parameter "fileName"
    .parameter "file"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/FileNotFoundException;
        }
    .end annotation

    .prologue
    const/4 v1, 0x0

    .line 156
    new-instance v0, Lcom/openfeint/internal/request/multipart/FilePartSource;

    invoke-direct {v0, p2, p3}, Lcom/openfeint/internal/request/multipart/FilePartSource;-><init>(Ljava/lang/String;Ljava/io/File;)V

    invoke-direct {p0, p1, v0, v1, v1}, Lcom/openfeint/internal/request/multipart/FilePart;-><init>(Ljava/lang/String;Lcom/openfeint/internal/request/multipart/PartSource;Ljava/lang/String;Ljava/lang/String;)V

    .line 157
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;)V
    .locals 1
    .parameter "name"
    .parameter "fileName"
    .parameter "file"
    .parameter "contentType"
    .parameter "charset"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/FileNotFoundException;
        }
    .end annotation

    .prologue
    .line 175
    new-instance v0, Lcom/openfeint/internal/request/multipart/FilePartSource;

    invoke-direct {v0, p2, p3}, Lcom/openfeint/internal/request/multipart/FilePartSource;-><init>(Ljava/lang/String;Ljava/io/File;)V

    invoke-direct {p0, p1, v0, p4, p5}, Lcom/openfeint/internal/request/multipart/FilePart;-><init>(Ljava/lang/String;Lcom/openfeint/internal/request/multipart/PartSource;Ljava/lang/String;Ljava/lang/String;)V

    .line 176
    return-void
.end method


# virtual methods
.method protected getSource()Lcom/openfeint/internal/request/multipart/PartSource;
    .locals 1

    .prologue
    .line 230
    iget-object v0, p0, Lcom/openfeint/internal/request/multipart/FilePart;->source:Lcom/openfeint/internal/request/multipart/PartSource;

    return-object v0
.end method

.method protected lengthOfData()J
    .locals 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 240
    iget-object v0, p0, Lcom/openfeint/internal/request/multipart/FilePart;->source:Lcom/openfeint/internal/request/multipart/PartSource;

    invoke-interface {v0}, Lcom/openfeint/internal/request/multipart/PartSource;->getLength()J

    move-result-wide v0

    return-wide v0
.end method

.method protected sendData(Ljava/io/OutputStream;)V
    .locals 7
    .parameter "out"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 203
    invoke-virtual {p0}, Lcom/openfeint/internal/request/multipart/FilePart;->lengthOfData()J

    move-result-wide v3

    const-wide/16 v5, 0x0

    cmp-long v3, v3, v5

    if-nez v3, :cond_0

    .line 222
    :goto_0
    return-void

    .line 211
    :cond_0
    const/16 v3, 0x1000

    new-array v2, v3, [B

    .line 212
    .local v2, tmp:[B
    iget-object v3, p0, Lcom/openfeint/internal/request/multipart/FilePart;->source:Lcom/openfeint/internal/request/multipart/PartSource;

    invoke-interface {v3}, Lcom/openfeint/internal/request/multipart/PartSource;->createInputStream()Ljava/io/InputStream;

    move-result-object v0

    .line 215
    .local v0, instream:Ljava/io/InputStream;
    :goto_1
    :try_start_0
    invoke-virtual {v0, v2}, Ljava/io/InputStream;->read([B)I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move-result v1

    .local v1, len:I
    if-gez v1, :cond_1

    .line 220
    invoke-virtual {v0}, Ljava/io/InputStream;->close()V

    goto :goto_0

    .line 216
    :cond_1
    const/4 v3, 0x0

    :try_start_1
    invoke-virtual {p1, v2, v3, v1}, Ljava/io/OutputStream;->write([BII)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_1

    .line 218
    .end local v1           #len:I
    :catchall_0
    move-exception v3

    .line 220
    invoke-virtual {v0}, Ljava/io/InputStream;->close()V

    .line 221
    throw v3
.end method

.method protected sendDispositionHeader(Ljava/io/OutputStream;)V
    .locals 2
    .parameter "out"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 186
    invoke-super {p0, p1}, Lcom/openfeint/internal/request/multipart/PartBase;->sendDispositionHeader(Ljava/io/OutputStream;)V

    .line 187
    iget-object v1, p0, Lcom/openfeint/internal/request/multipart/FilePart;->source:Lcom/openfeint/internal/request/multipart/PartSource;

    invoke-interface {v1}, Lcom/openfeint/internal/request/multipart/PartSource;->getFileName()Ljava/lang/String;

    move-result-object v0

    .line 188
    .local v0, filename:Ljava/lang/String;
    if-eqz v0, :cond_0

    .line 189
    sget-object v1, Lcom/openfeint/internal/request/multipart/FilePart;->FILE_NAME_BYTES:[B

    invoke-virtual {p1, v1}, Ljava/io/OutputStream;->write([B)V

    .line 190
    sget-object v1, Lcom/openfeint/internal/request/multipart/FilePart;->QUOTE_BYTES:[B

    invoke-virtual {p1, v1}, Ljava/io/OutputStream;->write([B)V

    .line 191
    invoke-static {v0}, Lcom/openfeint/internal/request/multipart/EncodingUtil;->getAsciiBytes(Ljava/lang/String;)[B

    move-result-object v1

    invoke-virtual {p1, v1}, Ljava/io/OutputStream;->write([B)V

    .line 192
    sget-object v1, Lcom/openfeint/internal/request/multipart/FilePart;->QUOTE_BYTES:[B

    invoke-virtual {p1, v1}, Ljava/io/OutputStream;->write([B)V

    .line 194
    :cond_0
    return-void
.end method
